package park_project.service.impl;

import java.util.ArrayList;

import park_project.entity.Admin;
import park_project.service.AdminService;

/*
 * 管理员类实现类
 * */
public class AdminServiceImpl implements AdminService {
    private ArrayList<Admin> adminList = new ArrayList<Admin>();
    //单例饿汉模式
    private static final AdminServiceImpl adminSeriver = new AdminServiceImpl();

    public static AdminServiceImpl getAdminSeriver() {
        return adminSeriver;
    }

    private AdminServiceImpl() {
    }

    @Override //管理员登录
    public Admin login(String username, String password) {//登录
        for (Admin admin : adminList) {
            if (admin.getUsername().equals(username) && admin.getPassword().equals(password)) {
                return admin;
            }
        }
        return null;
    }

    @Override //添加管理员
    public boolean register(Admin admin) {
        boolean flag = adminList.add(admin);//添加管理员
        return flag;
    }

}
